<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>GtkGradient</title>
<meta name="generator" content="DocBook XSL Stylesheets V1.76.1">
<link rel="home" href="index.html" title="GTK+ 3 参考手册">
<link rel="up" href="theming.html" title="Part III. GTK+中的主题">
<link rel="prev" href="gtk3-GtkSymbolicColor.html" title="GtkSymbolicColor">
<link rel="next" href="gtk3-GtkIconTheme.html" title="GtkIconTheme">
<meta name="generator" content="GTK-Doc V1.18 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2">
<tr valign="middle">
<td><a accesskey="p" href="gtk3-GtkSymbolicColor.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
<td><a accesskey="u" href="theming.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
<th width="100%" align="center">GTK+ 3 参考手册</th>
<td><a accesskey="n" href="gtk3-GtkIconTheme.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
</tr>
<tr><td colspan="5" class="shortcuts">
<a href="#gtk3-GtkGradient.synopsis" class="shortcut">Top</a>
                   | 
                  <a href="#gtk3-GtkGradient.description" class="shortcut">Description</a>
</td></tr>
</table>
<div class="refentry">
<a name="gtk3-GtkGradient"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="gtk3-GtkGradient.top_of_page"></a>GtkGradient</span></h2>
<p>GtkGradient — Gradients</p>
</td>
<td valign="top" align="right"></td>
</tr></table></div>
<div class="refsynopsisdiv">
<a name="gtk3-GtkGradient.synopsis"></a><h2>Synopsis</h2>
<pre class="synopsis">
#include &lt;gtk/gtk.h&gt;

                    <a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient">GtkGradient</a>;
<a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="returnvalue">GtkGradient</span></a> *       <a class="link" href="gtk3-GtkGradient.html#gtk-gradient-new-linear" title="gtk_gradient_new_linear ()">gtk_gradient_new_linear</a>             (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> x0</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> y0</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> x1</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> y1</code></em>);
<a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="returnvalue">GtkGradient</span></a> *       <a class="link" href="gtk3-GtkGradient.html#gtk-gradient-new-radial" title="gtk_gradient_new_radial ()">gtk_gradient_new_radial</a>             (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> x0</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> y0</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> radius0</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> x1</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> y1</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> radius1</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="gtk3-GtkGradient.html#gtk-gradient-add-color-stop" title="gtk_gradient_add_color_stop ()">gtk_gradient_add_color_stop</a>         (<em class="parameter"><code><a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="type">GtkGradient</span></a> *gradient</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> offset</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gtk3-GtkSymbolicColor.html#GtkSymbolicColor" title="GtkSymbolicColor"><span class="type">GtkSymbolicColor</span></a> *color</code></em>);
<a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="returnvalue">GtkGradient</span></a> *       <a class="link" href="gtk3-GtkGradient.html#gtk-gradient-ref" title="gtk_gradient_ref ()">gtk_gradient_ref</a>                    (<em class="parameter"><code><a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="type">GtkGradient</span></a> *gradient</code></em>);
<span class="returnvalue">void</span>                <a class="link" href="gtk3-GtkGradient.html#gtk-gradient-unref" title="gtk_gradient_unref ()">gtk_gradient_unref</a>                  (<em class="parameter"><code><a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="type">GtkGradient</span></a> *gradient</code></em>);
<a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            <a class="link" href="gtk3-GtkGradient.html#gtk-gradient-resolve" title="gtk_gradient_resolve ()">gtk_gradient_resolve</a>                (<em class="parameter"><code><a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="type">GtkGradient</span></a> *gradient</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gtk3-GtkStyleProperties.html#GtkStyleProperties" title="struct GtkStyleProperties"><span class="type">GtkStyleProperties</span></a> *props</code></em>,
                                                         <em class="parameter"><code><a href="../cairo/cairo-cairo-pattern-t.html#cairo-pattern-t"><span class="type">cairo_pattern_t</span></a> **resolved_gradient</code></em>);
</pre>
</div>
<div class="refsect1">
<a name="gtk3-GtkGradient.description"></a><h2>Description</h2>
<p>
GtkGradient is a boxed type that represents a gradient.
It is the result of parsing a
<a class="link" href="gtk3-GtkCssProvider.html#gtkcssprovider-gradients" title="Gradients">gradient expression</a>.
To obtain the gradient represented by a GtkGradient, it has to
be resolved with <a class="link" href="gtk3-GtkGradient.html#gtk-gradient-resolve" title="gtk_gradient_resolve ()"><code class="function">gtk_gradient_resolve()</code></a>, which replaces all
symbolic color references by the colors they refer to (in a given
context) and constructs a <a href="../cairo/cairo-cairo-pattern-t.html#cairo-pattern-t"><span class="type">cairo_pattern_t</span></a> value.
</p>
<p>
It is not normally necessary to deal directly with <a href="gtk3-GtkGradient.html#GtkGradient"><span class="type">GtkGradients</span></a>,
since they are mostly used behind the scenes by <a class="link" href="gtk3-GtkStyleContext.html#GtkStyleContext" title="struct GtkStyleContext"><span class="type">GtkStyleContext</span></a> and
<a class="link" href="gtk3-GtkCssProvider.html#GtkCssProvider" title="struct GtkCssProvider"><span class="type">GtkCssProvider</span></a>.
</p>
</div>
<div class="refsect1">
<a name="gtk3-GtkGradient.details"></a><h2>Details</h2>
<div class="refsect2">
<a name="GtkGradient"></a><h3>GtkGradient</h3>
<pre class="programlisting">typedef struct _GtkGradient GtkGradient;</pre>
<p>
</p>
</div>
<hr>
<div class="refsect2">
<a name="gtk-gradient-new-linear"></a><h3>gtk_gradient_new_linear ()</h3>
<pre class="programlisting"><a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="returnvalue">GtkGradient</span></a> *       gtk_gradient_new_linear             (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> x0</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> y0</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> x1</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> y1</code></em>);</pre>
<p>
Creates a new linear gradient along the line defined by (x0, y0) and (x1, y1). Before using the gradient
a number of stop colors must be added through <a class="link" href="gtk3-GtkGradient.html#gtk-gradient-add-color-stop" title="gtk_gradient_add_color_stop ()"><code class="function">gtk_gradient_add_color_stop()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>x0</code></em> :</span></p></td>
<td>X coordinate of the starting point</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>y0</code></em> :</span></p></td>
<td>Y coordinate of the starting point</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>x1</code></em> :</span></p></td>
<td>X coordinate of the end point</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>y1</code></em> :</span></p></td>
<td>Y coordinate of the end point</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A newly created <a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="type">GtkGradient</span></a>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 3.0</p>
</div>
<hr>
<div class="refsect2">
<a name="gtk-gradient-new-radial"></a><h3>gtk_gradient_new_radial ()</h3>
<pre class="programlisting"><a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="returnvalue">GtkGradient</span></a> *       gtk_gradient_new_radial             (<em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> x0</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> y0</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> radius0</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> x1</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> y1</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> radius1</code></em>);</pre>
<p>
Creates a new radial gradient along the two circles defined by (x0, y0, radius0) and
(x1, y1, radius1). Before using the gradient a number of stop colors must be added
through <a class="link" href="gtk3-GtkGradient.html#gtk-gradient-add-color-stop" title="gtk_gradient_add_color_stop ()"><code class="function">gtk_gradient_add_color_stop()</code></a>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>x0</code></em> :</span></p></td>
<td>X coordinate of the start circle</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>y0</code></em> :</span></p></td>
<td>Y coordinate of the start circle</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>radius0</code></em> :</span></p></td>
<td>radius of the start circle</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>x1</code></em> :</span></p></td>
<td>X coordinate of the end circle</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>y1</code></em> :</span></p></td>
<td>Y coordinate of the end circle</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>radius1</code></em> :</span></p></td>
<td>radius of the end circle</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>A newly created <a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="type">GtkGradient</span></a>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 3.0</p>
</div>
<hr>
<div class="refsect2">
<a name="gtk-gradient-add-color-stop"></a><h3>gtk_gradient_add_color_stop ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                gtk_gradient_add_color_stop         (<em class="parameter"><code><a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="type">GtkGradient</span></a> *gradient</code></em>,
                                                         <em class="parameter"><code><a href="../glib/glib-Basic-Types.html#gdouble"><span class="type">gdouble</span></a> offset</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gtk3-GtkSymbolicColor.html#GtkSymbolicColor" title="GtkSymbolicColor"><span class="type">GtkSymbolicColor</span></a> *color</code></em>);</pre>
<p>
Adds a stop color to <em class="parameter"><code>gradient</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>gradient</code></em> :</span></p></td>
<td>a <a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="type">GtkGradient</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>offset</code></em> :</span></p></td>
<td>offset for the color stop</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>color</code></em> :</span></p></td>
<td>color to use</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 3.0</p>
</div>
<hr>
<div class="refsect2">
<a name="gtk-gradient-ref"></a><h3>gtk_gradient_ref ()</h3>
<pre class="programlisting"><a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="returnvalue">GtkGradient</span></a> *       gtk_gradient_ref                    (<em class="parameter"><code><a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="type">GtkGradient</span></a> *gradient</code></em>);</pre>
<p>
Increases the reference count of <em class="parameter"><code>gradient</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>gradient</code></em> :</span></p></td>
<td>a <a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="type">GtkGradient</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>The same <em class="parameter"><code>gradient</code></em>
</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 3.0</p>
</div>
<hr>
<div class="refsect2">
<a name="gtk-gradient-unref"></a><h3>gtk_gradient_unref ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>                gtk_gradient_unref                  (<em class="parameter"><code><a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="type">GtkGradient</span></a> *gradient</code></em>);</pre>
<p>
Decreases the reference count of <em class="parameter"><code>gradient</code></em>, freeing its memory
if the reference count reaches 0.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody><tr>
<td><p><span class="term"><em class="parameter"><code>gradient</code></em> :</span></p></td>
<td>a <a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="type">GtkGradient</span></a>
</td>
</tr></tbody>
</table></div>
<p class="since">Since 3.0</p>
</div>
<hr>
<div class="refsect2">
<a name="gtk-gradient-resolve"></a><h3>gtk_gradient_resolve ()</h3>
<pre class="programlisting"><a href="../glib/glib-Basic-Types.html#gboolean"><span class="returnvalue">gboolean</span></a>            gtk_gradient_resolve                (<em class="parameter"><code><a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="type">GtkGradient</span></a> *gradient</code></em>,
                                                         <em class="parameter"><code><a class="link" href="gtk3-GtkStyleProperties.html#GtkStyleProperties" title="struct GtkStyleProperties"><span class="type">GtkStyleProperties</span></a> *props</code></em>,
                                                         <em class="parameter"><code><a href="../cairo/cairo-cairo-pattern-t.html#cairo-pattern-t"><span class="type">cairo_pattern_t</span></a> **resolved_gradient</code></em>);</pre>
<p>
If <em class="parameter"><code>gradient</code></em> is resolvable, <em class="parameter"><code>resolved_gradient</code></em> will be filled in
with the resolved gradient as a cairo_pattern_t, and <a href="../glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> will
be returned. Generally, if <em class="parameter"><code>gradient</code></em> can't be resolved, it is
due to it being defined on top of a named color that doesn't
exist in <em class="parameter"><code>props</code></em>.
</p>
<div class="variablelist"><table border="0">
<col align="left" valign="top">
<tbody>
<tr>
<td><p><span class="term"><em class="parameter"><code>gradient</code></em> :</span></p></td>
<td>a <a class="link" href="gtk3-GtkGradient.html#GtkGradient" title="GtkGradient"><span class="type">GtkGradient</span></a>
</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>props</code></em> :</span></p></td>
<td>
<a class="link" href="gtk3-GtkStyleProperties.html#GtkStyleProperties" title="struct GtkStyleProperties"><span class="type">GtkStyleProperties</span></a> to use when resolving named colors</td>
</tr>
<tr>
<td><p><span class="term"><em class="parameter"><code>resolved_gradient</code></em> :</span></p></td>
<td>return location for the resolved pattern. <span class="annotation">[<acronym title="Parameter for returning results. Default is transfer full."><span class="acronym">out</span></acronym>]</span>
</td>
</tr>
<tr>
<td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td>
<td>
<a href="../glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the gradient has been resolved</td>
</tr>
</tbody>
</table></div>
<p class="since">Since 3.0</p>
</div>
</div>
</div>
<div class="footer">
<hr>
          Generated by GTK-Doc V1.18</div>
</body>
</html>